<%--suppress ALL --%>
<html lang="utf-8">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<head>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
</head>
<body>

<h2>Hello World!</h2>
<div class="time">aa</div>
<h1>Servlet小例子</h1>
<hr>
<a href="servlet/HelloServlet">Get方式请求HellowServlet</a>


<form action="servlet/HelloServlet" method="post">
    <input type="text" name ="name" >
    <div><img id="image" src="/servlet/imageServlet"><input id="" type="button" value="切换验证码" onclick="changeImage();"></div>
    <input type="submit" value="Post方式请求HelloServlet">
</form>

</body>
<script>

$(function () {
    alert("js");
    $.ajax({
        url:"http://localhost:8080/servlet/refreshServlet",
        async:false,
        success:function(data){
            //alert("yes"+data);
            $(".time").html(data);
        }
    })
})

    function changeImage() {
    var url = $("#image").attr("src");
    console.log(url);
        $.ajax({
            url:"http://localhost:8080/servlet/imageServlet",
            async:false,
            success:function(data){
                //alert("yes"+data);
                $("#image").attr("src",url);
            }
        })
    }

</script>
</html>
